package com.dong.design.memento.memento_prototype;

/**
 * Originator 创建并在 Memento 对象中存储状态。
 *
 * @author jianyang206881
 * @date 2018/6/27
 */
public class Originator {
    private Hero hero;

    public Hero getHero() {
        return hero;
    }

    public void setHero(Hero hero) {
        this.hero = hero;
    }

    public HeroMemento saveStateToMemento() throws CloneNotSupportedException {
        return new HeroMemento((Hero) hero.clone());
    }

    public void getStateFromMemento(HeroMemento heroMemento) {
        hero = heroMemento.getHero();
    }

}
